package com.jdkreader.concurrency.queue;

public class Jammer implements Runnable{

    private ToastQueue butteredQueue,finishedQueue;

    public Jammer(ToastQueue buttered, ToastQueue finished) {
        this.butteredQueue = buttered;
        this.finishedQueue = finished;
    }

    @Override
    public void run() {
        try{
            while(!Thread.interrupted()){
                Toast t = butteredQueue.take();
                t.jam();
                System.out.println(t+" jam");
                finishedQueue.put(t);
            }
        }catch(InterruptedException e){
            e.printStackTrace();
        }
        System.out.println("Jammer off");
    }
}
